import ttkbootstrap as ttkb

from app.util.class_loader import scan_classes

"""基础视图类，所有视图都继承自此类"""


class View(ttkb.Frame):
    name = "aa"

    def __init__(self, parent, controller):
        super().__init__(parent)
        self.controller = controller
        self.create_widgets()

    def create_widgets(self):
        """创建视图控件，子类需要实现此方法"""
        pass

    def on_close(self):
        pass


def get_views():
    view_classes = scan_classes("app/view", View)
    # menu_list = []
    # for item in menu_map:
    #     top_menu_name = item[1]
    #     dir_name = item[0]
    #     is_add = item[2]
    #     top_menu = []
    #     second_menu = []
    #     for cls in view_classes:
    #         if dir_name in cls.__module__:
    #             menu_name = cls.__name__
    #             menu_model = cls.__module__
    #             second_menu.append(menu_name)
    #             second_menu.append(menu_model)
    #         # 生成菜单和主控制器所需要的List清单
    #         print(f"- {cls.__name__} (模块: {cls.__module__})")
    #     top_menu.append(top_menu_name)
    #     top_menu.append(second_menu)
    return view_classes


if __name__ == "__main__":
    model = get_views()
    print(model)
